-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android textureview player #1
Conversation
null-safe support
@@ -43,6 +46,27 @@ class UnityPlayerUtils { | |||
if (!reInitialize) { | |||
activity.window.setFormat(PixelFormat.RGBA_8888) | |||
unityPlayer = UnityPlayer(activity, ule) | |||
|
|||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand any of this lol. Which is fine. Just one question out of curiosity. This if seems to be checking if the version number is below zero? Wondering what this is checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build.VERSION_CODES.O
at first glance does look like a 0. I wish they didn't truncate "Oreo" to "O". At runtime this constant int is 26. https://developer.android.com/reference/android/os/Build.VERSION_CODES#O
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding what the code does, the majority of the work is happening within the unity generated library via unityPlayer!!.addViewToPlayer(view, true)
. The code above that is instantiating a TextureView
from the Android SDK and setting it up so that the unity player view renders to it. The unity player shows our newly made TextureView
because calling addViewToPlayer
swaps the internal surface with our TextureView
.
This branch will allow all supported android devices to render an unobstructed unity flutter widget view. This is done by calling
UnityPlayer::addViewToPlayer()
to swap the built inSurfaceView
with aTextureView
. Only android devices older than SDK version 26 (Oreo) will have this change made at runtime.The code in this branch is based on comments from this ticket: juicycleff#190